package org.jadestudio.dsdown.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.jadestudio.dsdown.entity.ManageAdminLogin;
import org.jadestudio.dsdown.entity.ManageArticle;
import org.jadestudio.dsdown.entity.ManageGame;
import org.jadestudio.dsdown.entity.ManageGameDownloads;
import org.jadestudio.dsdown.entity.ManageGamePic;
import org.jadestudio.dsdown.entity.ManageGamePublishCompany;
import org.jadestudio.dsdown.entity.ManageGamePurchase;
import org.springframework.stereotype.Component;

import com.ibatis.sqlmap.client.SqlMapClient;

@Component
public class ArticleManageDao {
	@Resource
	private SqlMapClient sqlMapClient;
	
	/**
	 * 
	 * 得到文章类型种类
	 */
	public List<java.util.Map> getArticleTypeList() throws Exception{
		return this.sqlMapClient.queryForList("test.ArticleTypeQuery");
	}
	
	/**
	 * 游戏模糊查询（返回json）
	 * @param requestString
	 * @return
	 * @throws Exception
	 */
	public List<java.util.Map> gameQueryByName(String requestString) throws Exception{
		return this.sqlMapClient.queryForList("test.gameQueryByName",requestString);
	}
	
	/**
	 * 文章新增逻辑
	 * @param manageArticle
	 * @return
	 * @throws Exception
	 */
	public String articleAdd(ManageArticle manageArticle) throws Exception{
		return (String)this.sqlMapClient.queryForObject("test.insertArticle",manageArticle);
	}
	
	/**
	 * 文章修改逻辑
	 * @param manageArticle
	 * @return
	 * @throws Exception
	 */
	public String articleModify(ManageArticle manageArticle) throws Exception{
		return (String)this.sqlMapClient.queryForObject("test.modifyArticle",manageArticle);
	}
	
	
	/**
	 * 文章模糊查询(带分页)
	 */
	public List<java.util.Map> articleQueryByPaging(Map queryMap) throws Exception{
			return this.sqlMapClient.queryForList("test.selectArticle",queryMap);
	}
	
	/**
	 * 文章数量查询(带分页)
	 */
	public int articleCountQuery(Map queryMap) throws Exception{
			return (Integer)this.sqlMapClient.queryForObject("test.getArticleCount",queryMap);
	}
	
	
	/**
	 * 文章删除
	 * @param articleId
	 * @return
	 * @throws Exception
	 */
	public int articleDeleteById(String articleId) throws Exception{
		this.sqlMapClient.delete("test.gameArticleDeleteById",articleId);
		this.sqlMapClient.delete("test.articleDeleteById",articleId);
		return 1;
	}
	
	/**
	 * 文章查询BYID
	 * @param articleId
	 * @return
	 * @throws Exception
	 */
	public Map articleQueryById(String articleId) throws Exception{
		return (Map)this.sqlMapClient.queryForObject("test.articleQueryById", articleId);
	}
	
	/**
	 * 游戏文章关联表t11_game_article查询BYID
	 * @param articleId
	 * @return
	 * @throws Exception
	 */
	public List<Map> gameArticleQueryByArticleId(String articleId)throws Exception{
		return (List<Map>)this.sqlMapClient.queryForList("test.gameArticleQueryByArticleId",articleId);
	}
	
	

	
	
	
	
}
